package com.wxsh.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.wxsh.dao.UserMapper;
import com.wxsh.entity.User;
import com.wxsh.service.UserService;

@Service("userServiceImpl")
public class UserServiceImpl implements UserService {
	
	@Autowired
	private UserMapper userMapper;

	@Override
	public User findById(Integer id) {
		User user = userMapper.selectByPrimaryKey(id);
		return user;
	}

    @Override
    @Transactional
    public User addUser(User user) {
        int rows = userMapper.insertSelective(user);
        if(rows < 1){
            throw new RuntimeException("Add user failure.");
        }
        return user;
    }

}
